package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.wxcollect.AddOrDeleteData;
import com.cskaoyan.bean.wxcollect.AddOrDeleteReq;
import com.cskaoyan.bean.wxcollect.WxCollectData;
import com.cskaoyan.service.WxCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: yudefu
 * @date 2021年06月07日  17:41
 * @description: 收藏模块
 */

@RestController
@RequestMapping("wx/collect")
public class WxCollectController {

    @Autowired
    WxCollectService wxCollectService;

    @RequestMapping("list")
    public BaseRespVo getCollectList(Byte type,Integer page,Integer size) {

        WxCollectData wxCollectData = wxCollectService.getCollectList(type, page, size);

        return BaseRespVo.ok(wxCollectData);
    }


    @RequestMapping("addordelete")
    public BaseRespVo addOrDelete(@RequestBody AddOrDeleteReq addOrDeleteReq) {

        AddOrDeleteData addOrDeleteData = wxCollectService.addOrDelete(addOrDeleteReq);

        if (addOrDeleteData == null) {
            return BaseRespVo.fail();
        }

        return BaseRespVo.ok(addOrDeleteData);
    }
}
